package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.DateUtil;
import com.alibaba.druid.support.json.JSONUtils;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
public class TravelCommend {

    public static final int TYPE_WEEK = 0;
    public static final int TYPE_MONTH = 1;
    public static final int TYPE_STRATEGY = 2;

    private Long id;

    private Travel travel;  //推荐绑定游记

    private String title;   //推荐大标题

    private String subTitle;    //推荐小标题

    private String coverUrl;    //推荐封面
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date schedule;  //推荐日期

    private int type;   //推荐类型,周推荐,月推荐,攻略推荐

    public String getTypeDisplay(){
        if(type == TYPE_WEEK){
            return "周推荐";
        }else if(type == TYPE_MONTH){
            return "月推荐";
        }else if(type == TYPE_STRATEGY){
            return "攻略推荐";
        }else{
            return "";
        }

    }

    public String getJsonString(){
        Map<String, Object> map = new HashMap<>();
        map.put("id",id);
        map.put("travelId",travel.getId());
        map.put("title",title);
        map.put("subTitle",subTitle);
        map.put("coverUrl",coverUrl);
        map.put("schedule", DateUtil.date2string(schedule,"yyyy-MM-dd"));
        map.put("type",type);
        return JSONUtils.toJSONString(map);
    }
}